/*
 * @Author: xinqiao lxq1990.0716@qq.com
 * @Date: 2023-12-13 16:25:36
 * @LastEditors: xinqiao lxq1990.0716@qq.com
 * @LastEditTime: 2024-01-26 18:37:44
 * @FilePath: \h5-components\src\utils\util.ts
 * @Description: 通用工具类
 */

const PHONE_HEAD_HEIGHT = 96

/**
 * 校验是否PC端
 * @returns 
 */
export const checkPc = () => {
  const agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]
  for (let i = 0, len = agents.length; i < len; i++) {
    if (navigator.userAgent.indexOf(agents[i]) > 0) return false
  }
  return true
}

/**
 * 获取手机头部距顶距离
 * @returns 
 */
export const getHeadTop = () => {
  return checkPc() ? PHONE_HEAD_HEIGHT : 0
}
